 

package com.zdkj.subway.rca.controller;


import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.subway.rca.dto.out.SwCkClearingReportQrDTO;

import com.zdkj.subway.rca.service.SwCkClearingReportQrService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 二维码应收应付差异统计表
 *
 * @author stw
 * @date 2020-11-10 11:58:51
 */
@RestController
@AllArgsConstructor
@RequestMapping("/swckclearingreportqr" )
@Api(value = "swckclearingreportqr", tags = "清分及划账 - 清分及划账报表查看 - 二维码应收应付差异统计表管理")
public class SwCkClearingReportQrController {

    private final  SwCkClearingReportQrService swCkClearingReportQrService;

    /**
     * 查询
     * @return
     */
    @ApiOperation(value = "查询", notes = "查询")
    @GetMapping("/list" )
    public R getSwCkClearingReportQrList(String startDate, String endDate) {
        List<SwCkClearingReportQrDTO> dtos = swCkClearingReportQrService.getSwCkClearingReportQrList(startDate,endDate);
        return R.ok(dtos);
    }

    /**
     * 设置回复期限初始化
     */
    @ApiOperation(value = "二维码应收应付差异统计表-设置回复期限初始化", notes = "二维码应收应付差异统计表-设置回复期限初始化")
    @SysLog("二维码应收应付差异统计表-设置回复期限初始化" )
    @GetMapping("/setReplayLimitPre" )
    @PreAuthorize("@pms.hasPermission('sw_ck_clearing_report_qr_setReplayLimit')" )
    public R setReplayLimitPre(@RequestParam(value = "ids") List<Long> ids) {
        if(ids == null || ids.isEmpty()){
            return R.failed();
        }
        return R.ok(swCkClearingReportQrService.setReplayLimitPre(ids));
    }


    /**
     * 设置回复期限
     */
    @ApiOperation(value = "二维码应收应付差异统计表-设置回复期限,只需ID和回复期限", notes = "二维码应收应付差异统计表-设置回复期限,只需ID和回复期限")
    @SysLog("二维码应收应付差异统计表-设置回复期限" )
    @PostMapping("/setReplayLimit" )
    @PreAuthorize("@pms.hasPermission('sw_ck_clearing_report_qr_setReplayLimit')" )
    public R setReplayLimit(@RequestBody List<SwCkClearingReportQrDTO> swCkClearingReportQrDTOs) {
        if(swCkClearingReportQrDTOs == null || swCkClearingReportQrDTOs.isEmpty()){
            return R.failed();
        }
        return R.ok(swCkClearingReportQrService.setReplayLimit(swCkClearingReportQrDTOs));
    }

    /**
     * 报送协查
     */
    @ApiOperation(value = "报送协查", notes = "报送协查")
    @GetMapping({"/send"})
    @SysLog("二维码应收应付差异统计表-报送协查")
    @PreAuthorize("@pms.hasPermission('sw_ck_clearing_report_qr_send')")
    public R send(@RequestParam(value = "ids") List<Long> ids) {
        if(ids == null || ids.isEmpty()){
            return R.failed();
        }
        return R.ok(swCkClearingReportQrService.send(ids));
    }

    /**
     * 导出
     * @param
     * @return
     */
    @ApiOperation(value = "导出", notes = "导出")
    @GetMapping({"/export"})
    @SysLog("二维码应收应付差异统计表-导出")
    @PreAuthorize("@pms.hasPermission('sw_ck_clearing_report_qr_export')")
    public void export(@RequestParam(value = "ids") List<Long> ids, HttpServletResponse response) {
        if(ids == null || ids.isEmpty()){
            return;
        }
        swCkClearingReportQrService.export(ids,response);
    }

}
